package stack;

import java.util.Stack;

public class TwoStackForQueue {
	
	Stack<Integer> s1;
	Stack<Integer> s2;
 	public TwoStackForQueue() {
		s1 = new Stack<>();
		s2 = new Stack<>();
	}
 	
 	public void appendTail(int val) {
 		s1.push(val);
 	}
 	
 	public int deleteHead() {
 		int result = -1;
 		
 		if(s2.isEmpty()) {
 			while(s1.size()>0) {
 				s2.push(s1.pop());
 			}
 		}
 		if(s2.pop()!= null) {
 			result = s2.pop();
 		}
 		
 		
 		if(s1.empty()) {
 			while(s1.size()>0) {
 				s1.push(s2.pop());
 			}
 		}
 		return result;
 		
 		
 	}
	
	
	
	
 	public static void main(String[] args) {
		TwoStackForQueue twoStackForQueue = new TwoStackForQueue();
		twoStackForQueue.appendTail(1);
		int i = twoStackForQueue.deleteHead();
		System.out.println(i);
	}

}
